package com.mark.springbootvideo.service.impl;

import com.github.pagehelper.PageHelper;
import com.mark.springbootvideo.entity.Video;
import com.mark.springbootvideo.mapper.VideoMapper;
import com.mark.springbootvideo.service.VideoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: MARK
 * @Date: 2019/9/8 08:42
 * @Version: 1.0.0
 * @Description:
 */
@Service
@Slf4j
public class VideoServiceImpl implements VideoService {
    @Resource
    private VideoMapper videoMapper;

    @Override
    public List<Video> findAll(Integer page, Integer size) {
        PageHelper.startPage(page, size);
        return videoMapper.findAll();
    }

    @Override
    public Video findById(Integer id) {
        return videoMapper.findById(id);
    }

    @Override
    public void update(Video video) {
        videoMapper.update(video);
    }

    @Override
    public void delete(Integer id) {
        videoMapper.delete(id);
    }

    @Override
    public void save(Video video) {
        videoMapper.save(video);
        log.info("存入的id为: " + video.getId());
    }
}
